home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / gfx / mv2_x.lha / MultiView.e
Text File  |  1995-08-03  |  8KB  |  231 lines

  1. /* 
  2. Introduction
  3. ------------
  4. This little program should be named MultiView and placed in the C:
  5. directory or somewhere else in the search path.
  6. It was written out of frustration. If you are using OS 2.x and often
  7. download archives from Aminet or the like, you probably know this
  8. situation: doubleclick on an icon and a requester pops up "program
  9. multiview cannot be located". This is especially annoying for CDs,
  10. because it is impossible to change the default tool.
  11. Here is where this program comes in. It is called instead of the 3.x
  12. MultiView and there is a pre-configured viewer that you like best
  13. for all the usual file extensions.
  14.  
  15. How to use it?
  16. --------------
  17. Very simple, if you have AmigaE by Wouter van Oortmerssen. 
  18. Thanks Wouter for this incredible piece of software and the support!
  19. It was written using version 3.1a, but might work with earlier
  20. versions too.
  21. (If not, get the latest version from Aminet and try the demo and
  22. register afterwards 8-) )
  23. I put in my favourite viewers (players can also be used). To change
  24. that, just edit the source code to fit your needs and compile it.
  25. As the last step, put it in your C: directory as MultiView.
  26. Then you are set.
  27. In addition, I created a Toolmanager dock for my program. That makes
  28. it possible to simply drag a document on this icon and it is viewed.
  29. (great for readme files on Aminet CDs without icons)
  30.  
  31. Requirements
  32. ------------
  33. - Amiga computer (kind of obvious)
  34. - enough memory to load the program and to display all
  35.   the requesters (and for the viewers and data as well)
  36. - OS 2.x (3.x and more comes with a real MultiView, so why bother?)
  37.  
  38. Some problems
  39. -------------
  40. - viewers must be in C: or complete path must be coded, when used
  41.   from WB
  42.   (DOS.library`s Execute function related)
  43.   (any ideas for fixing, please contact me)
  44. - doesn`t replace OS 3.x data types
  45.   (it doesn`t even try 8-( )
  46. - no external prefs file/program
  47.   (faster for same reason)
  48.   data types do not change very often
  49. - can handle only commands up to 512 characters
  50.   (including parameters, quotes, spaces, colons, slashes ...)
  51.   (max. CLI command length is 512)
  52. - file needs to have an extension (.something) to recognize
  53.   file type (currently up to 6 characters)
  54.   otherwise the requester for unknown file types comes up
  55.  
  56. Legal Stuff
  57. -----------
  58. This program was written, using some example routines from the
  59. AmigaE_v3.1a package, (thanks again to Wouter) by:
  60.  
  61. Horst Schumann
  62. Helmstedter Str. 18
  63. 39167 Irxleben
  64. Germany
  65.  
  66. e-mail: hschuman@cs.uni-magdeburg.de
  67. WWW: http://www.cs.uni-magddeburg.de/~hschuman/hschuman.html (links only)
  68.  
  69.  
  70. I call it anythingware (same as giftware)! Everybody can use it,
  71. modify it, compile it, re-release it, etc. provided he/she (Are
  72. there any girls using the Amiga? I'd love to hear from you!)
  73. sends me anything like e-mails, postcards, letters, money, Amiga
  74. equipment, Amigas (no PCs, please!), etc., but if you can`t
  75. afford any of it, please use it anyway, it might be useful. Own
  76. programs, especially those of the useful kind, are very much
  77. welcome too (uncrippled of course).
  78.  
  79. And now the standard disclaimer
  80. -------------------------------
  81. NO WARRANTY
  82. If something happens and you don`t want it, blame somebody else!
  83.  
  84. History
  85. -------
  86. This release got some requesters added in case the file type is
  87. unknown. Instead of using the default viewer a custom viewer can
  88. be selected.
  89.  
  90. Future Plans?
  91. -------------
  92. Who knows what the future will bring...
  93. */
  94.  
  95.  
  96.  
  97. OPT OSVERSION=37
  98.  
  99. MODULE 'workbench/startup','Asl','libraries/Asl'
  100.  
  101.  
  102. PROC get_extension(string,extension)
  103.   DEF pos
  104.   pos:=StrLen(string)-1
  105.   WHILE string[pos]<>"."
  106.     pos--
  107.   ENDWHILE
  108.   MidStr(extension,string,pos+1)
  109. ENDPROC
  110.  
  111.  
  112. PROC get_command(extension,command)        -> edit for own commands
  113.   LowerStr(extension)
  114.   IF StrCmp(extension,'guide')
  115.     StrCopy(command,'amigaguide "')
  116.   ELSEIF StrCmp(extension,'doc')
  117.     StrCopy(command,'muchmore "')
  118.   ELSEIF StrCmp(extension,'txt')
  119.     StrCopy(command,'muchmore "')
  120.   ELSEIF StrCmp(extension,'readme')
  121.     StrCopy(command,'muchmore "')
  122.   ELSEIF StrCmp(extension,'iff')
  123.     StrCopy(command,'work:utilities/display "')
  124.   ELSEIF StrCmp(extension,'ham')
  125.     StrCopy(command,'work:utilities/display "')
  126.   ELSE
  127.     unknown_type(command)
  128.   ENDIF
  129. ENDPROC
  130.  
  131. PROC unknown_type(command)
  132.   DEF result,req:PTR TO filerequester
  133.   result:=EasyRequestArgs(0,[20,0,
  134.                           'MV2.x',
  135.                           'Filetype unknown!',
  136.                           'Use Default Viewer|Select Viewer'],
  137.                           0,NIL)
  138.   IF result=1
  139.     StrCopy(command,'muchmore "')
  140.   ELSE
  141.     IF aslbase:=OpenLibrary('asl.library',37)
  142.       IF req:=AllocAslRequest(ASL_FILEREQUEST,
  143.                              [ASLFR_TITLETEXT,'Select viewer',
  144.                               ASLFR_POSITIVETEXT,'Use this viewer',
  145.                               ASLFR_NEGATIVETEXT,'Use default viewer',
  146.                               ASLFR_INITIALFILE,'MuchMore',
  147.                               ASLFR_INITIALDRAWER,'C:',
  148.                               ASLFR_REJECTICONS,TRUE,
  149.                               0,0])
  150.         IF AslRequest(req,0)
  151.           StrCopy(command,req.drawer)
  152.           IF command[StrLen(command)-1]<>":"
  153.             StrAdd(command,'/')
  154.           ENDIF
  155.           StrAdd(command,req.file)
  156.           StrAdd(command,' "')
  157.         ELSE
  158.           StrCopy(command,'muchmore "')
  159.         ENDIF
  160.         FreeAslRequest(req)
  161.       ELSE
  162.         EasyRequestArgs(0,[20,0,
  163.                         'MV2.x',
  164.                         'Could not open file requester!',
  165.                         'Use default viewer'],
  166.                         0,NIL)
  167.       ENDIF
  168.       CloseLibrary(aslbase)
  169.     ELSE
  170.       EasyRequestArgs(0,[20,0,
  171.                       'MV2.x',
  172.                       'Could not open Asl library!',
  173.                       'Use default viewer'],
  174.                       0,NIL)
  175.     ENDIF
  176.   ENDIF
  177. ENDPROC
  178.  
  179. PROC main()
  180.   DEF wb:PTR TO wbstartup       -> pointer to WBstartup object
  181.   DEF wbargs:PTR TO wbarg       -> pointer to WBarg object
  182.   DEF a                         -> just a counter
  183.   DEF template                  -> template for CLI argument parsing
  184.   DEF rdargs                    -> flag for ReadArgs result
  185.   DEF cliargs=NIL:PTR TO LONG   -> pointer for ReadArgs arguments
  186.   DEF command[512]:STRING       -> max. CLI command length is 511
  187.   DEF currentdir                -> save current dir when run from WB
  188.   DEF ext[6]:STRING             -> extension
  189.   
  190.   IF wbmessage=NIL                          -> started from CLI
  191.     template:='FILE/M'
  192.     rdargs:=ReadArgs(template,{cliargs},NIL)
  193.     IF rdargs
  194.       IF cliargs
  195.         a:=0
  196.         WHILE cliargs[a]                    -> Loop through arguments
  197.           IF InStr(cliargs[a],'.') > -1
  198.             get_extension(cliargs[a],ext)
  199.             get_command(ext,command)        -> execute command
  200.           ELSE
  201.             unknown_type(command)
  202.           ENDIF
  203.           StrAdd(command,cliargs[a])
  204.           StrAdd(command,'"')
  205.           Execute(command,0,stdout)         -> execute command
  206.           a++
  207.         ENDWHILE
  208.       ENDIF
  209.       FreeArgs(rdargs)
  210.     ENDIF
  211.   ELSE                                      -> started from WB
  212.     wb:=wbmessage
  213.     currentdir:=CurrentDir(wbargs[0].lock)
  214.     wbargs:=wb.arglist
  215.     FOR a:=1 TO wb.numargs-1
  216.       IF InStr(wbargs[a].name,'.') > -1
  217.         get_extension(wbargs[a].name,ext)
  218.         get_command(ext,command)            -> select command for extension
  219.       ELSE
  220.         unknown_type(command)
  221.       ENDIF
  222.       CurrentDir(wbargs[a].lock)            -> change to target dir
  223.       StrAdd(command,wbargs[a].name)
  224.       StrAdd(command,'"')
  225.       Execute(command,0,stdout)             -> execute command
  226.     ENDFOR
  227.     CurrentDir(currentdir)                  -> restore old current dir
  228.   ENDIF
  229. ENDPROC
  230.  
  231.